
using System;
using System.Linq;
using Csla;
using Csla.Data;
using Csla.Security;
using Csla.Validation;

namespace HousingInfo.Library
{ 
	public partial class NewsHouseBO : Csla.BusinessBase<NewsHouseBO>
	{

		#region Authorization Rules
		protected override void AddAuthorizationRules()
		{
			//TODO: Define authorization rules in NewsHouseBO
			//AuthorizationRules.AllowRead(NewsHouseIDProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(UserNameProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(AreaDetailIDProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(CategoryIDProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(CurrencyIDProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(HousingTypeIDProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(DocumentsProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(SurfaceAreaProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(DirectionProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(PriceProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(IsNegotiationProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(CreatedDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(PostDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(UpdatedDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(ExpireDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(TitleProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(NewsContentProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(UrlImageProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(ViewCountProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(IsExtensionProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(ExtensionDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(NumExtensionProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(IsPremiumProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(IsAdvertisementProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(UrlImageAdversitementProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(MessageProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(IsActiveProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(ActiveDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(NumPostProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(UnActiveDateProperty, "NewsHouseBOReadGroup");
			//AuthorizationRules.AllowRead(ReActiveDateProperty, "NewsHouseBOReadGroup");

			//AuthorizationRules.AllowWrite(UserNameProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(AreaDetailIDProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(CategoryIDProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(CurrencyIDProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(HousingTypeIDProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(DocumentsProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(SurfaceAreaProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(DirectionProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(PriceProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsNegotiationProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(CreatedDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(PostDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(UpdatedDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(ExpireDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(TitleProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(NewsContentProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(UrlImageProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(ViewCountProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsExtensionProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(ExtensionDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(NumExtensionProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsPremiumProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsAdvertisementProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(UrlImageAdversitementProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(MessageProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(IsActiveProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(ActiveDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(NumPostProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(UnActiveDateProperty, "NewsHouseBOWriteGroup");
			//AuthorizationRules.AllowWrite(ReActiveDateProperty, "NewsHouseBOWriteGroup");
		}

		protected static void AddObjectAuthorizationRules()
		{
			//TODO: Define object-level authorization rules of NewsHouseBO
			//AuthorizationRules.AllowCreate(typeof(NewsHouseBO), "NewsHouseBOCreateGroup"));
			//AuthorizationRules.AllowEdit(typeof(NewsHouseBO), "NewsHouseBOEditGroup"));
			//AuthorizationRules.AllowDelete(typeof(NewsHouseBO), "NewsHouseBODeleteGroup"));
		}
		#endregion //Authorization Rules
		private void AssignParentKey(HousingInfo.DataLinQ.NewsHouse data)
		{
			 //data.ParentId = ReadProperty<ParentBO>(ParentBOProperty).Id;
        }

        #region Lay 1 tin theo truong Temp de nhan biet ID
        #region Khai Bao Ham
        public static NewsHouseBO GetNewsHouseBO_ByTemp(string temp)
        {
            return DataPortal.Fetch<NewsHouseBO>(new FilterGetNewsHouseBO_ByTemp(temp));
        }
        #endregion

        #region khai bao tham so
        private class FilterGetNewsHouseBO_ByTemp
        {
            public string tem;
            public FilterGetNewsHouseBO_ByTemp(string temp)
            {
                this.tem = temp;
            }
        }
        #endregion//end khai bao tham so

        #region Truy cap du lieu
        private void DataPortal_Fetch(FilterGetNewsHouseBO_ByTemp criteria)
        {
            using (var mgr = ContextManager<HousingInfo.DataLinQ.HousingInfoDataContext>
                        .GetManager(Database.HousingInfoConnection))
            {
                var data = mgr.DataContext.NewsHouses
                        .Single(r => r.Temp == criteria.tem);

                OnMemberLoading(data);
                LoadProperty<int>(NewsHouseIDProperty, data.NewsHouseID);
                LoadProperty<string>(TempProperty, data.Temp);
                //OnMemberLoaded();

                ValidationRules.CheckRules();
            }//using

            //OnFetched();
        }
        #endregion
        #endregion
    }
}
